package com.sise.cn.task.service.impl;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.core.ChannelAwareMessageListener;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

/**
 * @ClassName RabbitMqHandle
 * @Description
 * @Author CCJ
 * @Date 2020/6/8 19:14
 **/
@Service
public class RabbitMqHandle implements ChannelAwareMessageListener {
    @Override
    public void onMessage(Message message, Channel channel) throws Exception {
        message.getMessageProperties().getConsumerQueue();
        // 消息确认接收
        channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
//        // 可重试失败
//        channel.basicNack(message.getMessageProperties().getDeliveryTag(), false, true);
//        // 消费失败
//        channel.basicNack(message.getMessageProperties().getDeliveryTag(), false, false);
//        //消息丢弃
//        channel.basicNack(message.getMessageProperties().getDeliveryTag(), false, false);
    }
}
